import request from '@/utils/request'

// 获取用户选择的频道列表
const getUserChannelListAPI = () => {
  return request({
    method: 'get',
    url: '/v1_0/user/channels'
  })
}

// 获取文章列表
const getArticleListAPI = ({
  channelId,
  timestamp = Date.now()
}) => {
  return request({
    method: 'get',
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp
    }
  })
}

// 文章 - 不感兴趣
const dislikeArticleAPI = ({ articleId }) => {
  return request({
    method: 'post',
    url: '/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}

// 文章 - 举报
const reportArticleAPI = ({
  target,
  type,
  remark
}) => {
  return request({
    method: 'post',
    url: '/v1_0/article/reports',
    data: {
      target,
      type,
      remark
    }
  })
}

// 获取所有频道列表
const getAllChannelListAPI = () => {
  return request({
    method: 'get',
    url: '/v1_0/channels'
  })
}

// 更新用户选择的频道列表
const updateUserChannelListAPI = ({ channels }) => {
  return request({
    method: 'put',
    url: '/v1_0/user/channels',
    data: {
      channels
    }
  })
}

// 按需导出
export {
  getUserChannelListAPI,
  getArticleListAPI,
  dislikeArticleAPI,
  reportArticleAPI,
  getAllChannelListAPI,
  updateUserChannelListAPI
}
